package ee.ut.cs.mc.madp.p2pdivider;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;

/**
 * Main activity for P2P divider application
 * 
 * @author Kaarel Jõgeva
 */
public class SetupActivity extends Activity {

    public static final String TAG = "SetupActivity";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
        dialogBuilder.setMessage("Do you want to host a new session or join an existing one?").setNegativeButton("Join existing", new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                Log.i(TAG, "Joining an existing session");
                Intent client = new Intent(getApplicationContext(), ClientActivity.class);
                startActivity(client);
            }

        }).setPositiveButton("Host new", new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                Log.i(TAG, "Creating new session");
                Intent host = new Intent(getApplicationContext(), HostActivity.class);
                startActivity(host);
            }

        }).create().show();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}
